package com.summer.LanQiao;
import java.util.Arrays;
import java.util.Scanner;

public class DanCiFenXi {
    //
    public static void E2(){
        int[][] arr = new int[101][101];
        int[][] srr = new int[101][101];
        arr[1][1] = 1;
        for (int i = 1; i < 101 ; i++) {
            for (int j = 1; j < 101 ; j++) {
                if (i==1&&j==1)continue;
                if (j==1&&(i-1)>=0){
                    arr[i][j] = arr[i-1][j]+1;
                }else if (j!=0&&(j-1)>=0){
                    arr[i][j] = arr[i][j-1]+2;
                }

            }
        }
        for (int i = 0; i <100 ; i++) {
            System.out.println(Arrays.toString(arr[i]));
        }
        for(int i=1;i<=100;++i)
            for(int j=1;j<=100;++j)
                srr[i][j] = srr[i-1][j]+srr[i][j-1]-srr[i-1][j-1]+arr[i][j];
        System.out.println("------------------------------------");
        for (int i = 0; i <100 ; i++) {
            System.out.println(srr[i][i]);
        }
    }
    //
    public static void E(){
        int[][] arr = new int[100][100];
        int[][] srr = new int[100][100];
        arr[0][0] = 1;
        for (int i = 0; i < 100 ; i++) {
            for (int j = 0; j < 100 ; j++) {
                if (i==0&&j==0)continue;
                if (j==0&&(i-1)>=0){
                    arr[i][j] = arr[i-1][j]+1;
                }else if (j!=0&&(j-1)>=0){
                    arr[i][j] = arr[i][j-1]+2;
                }

            }
        }
        for (int i = 0; i <100 ; i++) {
            System.out.println(Arrays.toString(srr[i]));
        }
        int count = 10;
        System.out.println(E1(arr,1,1,count));
    }
    public static int E1(int[][] arr,int i,int j,int count){
        if (count>2022||i+1>=100||j+1>=100){
            System.out.println(i+"--"+j);
            System.out.println(count);
            return i*j;
        }
        int a = i+1;
        int k = 0;
        count+=arr[i+1][j+1];
        while (a>=0&&k<=j+1){
            count+=arr[i+1][k++];
            a--;
        }
        int b = i+1;
        int g = 0;
        while (b>=0&&g<=j+1){
            count+=arr[g][j+1];
            b--;
        }

        return E1(arr, i+1, j+1, count);
    }
    //给定一个字母矩阵，如果矩阵中的某个位置不在四条边上，而且该位置上的字母小于其上下左右四个位置的字母，则称为一个山谷。
    //例如，对于如下矩阵
    public static void juZhen(){
        Scanner sc = new Scanner(System.in);
        char[][] chars = new char[30][60];
        for (int i = 0; i < 30; i++) {
            chars[i] = sc.nextLine().toCharArray();
        }
        int count = 0;
        for (int i = 1; i < 29 ; i++) {
            for (int j = 1; j < 59 ; j++) {
                if (i==0||j==0||i==29||j==59) continue;
                if (chars[i][j]<chars[i][j-1]&&chars[i][j]<chars[i][j+1]&&
                    chars[i][j]<chars[i+1][j]&&chars[i][j]<chars[i-1][j]){
                    count++;
                }
            }
        }
        System.out.println(count);
    }

    //小蓝特别喜欢调和级数 S(n)=1/1+1/2+1/3+1/4+…+1/n 。
    //请问，n 至少为多大时，S(n)>12
    public static void tiaoHe(int n){
        double count = 0;
        double a = 1;
        int b = 1;
       while (true){

           count += a / b;
           if (count > n) break;
           b += 1;

           System.out.println(count);
       }
        System.out.println(b);
    }
    public static void main(String[] args) {
        //tiaoHe(2);
       // juZhen();
        E2();
//        Scanner sc = new Scanner(System.in);
//        String s = sc.nextLine();
//        int[] arr = new int[26];
//        int index = -1;
//        for (int i = 0; i < s.length() ; i++) {
//             index = s.charAt(i) - 97;
//
//            arr[index] ++;
//        }
//        int max = 0;
//        int maxIndex = -1;
//        for (int i = 0; i < arr.length ; i++) {
//            if (arr[i] > max ){
//                max = arr[i];
//                maxIndex = i;
//            }
//        }
//
//        char zifu = (char) (maxIndex+97);
//        System.out.println(zifu);
//        System.out.println(max);
//        sc.close();
    }
}
